//
//  TestVC.swift
//  RunLoopDemo
//
//  Created by zhangjikuan on 2021/2/26.
//  Copyright © 2021 hsgd. All rights reserved.
//

import Foundation
import UIKit
class TestVC: UIViewController {
    var textLabel = UILabel.init()
    let name = "李白拜别杜甫"
    
    override func viewDidLoad() {
        title = "SWIFT"
        view.backgroundColor = .red
        textLabel.frame = CGRect.init(x: 0, y: 0, width: 100, height: 100)
        textLabel.text = "HHAIK"
        view.addSubview(textLabel)
        
        let label = UILabel.init(frame: CGRect.init(x: 0, y: 150, width: view.frame.width, height: 100))
        label.text = name
        label.textColor = .yellow
        label.font = .systemFont(ofSize: 18)
        view.addSubview(label)
        var timer = Timer.init(timeInterval: 2,
                               target:self,
                               selector: #selector(timeTest),
                               userInfo: nil,
                               repeats: true)
        timer.fire()
        
        var nums = 0
        
        timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { (timer) in
            print("block");
            nums+=1
            label.text = self.name+String(nums)
        });
        
        let runloop = RunLoop.init()
        runloop.add(timer, forMode: .common)
        
    }
    @objc
    func timeTest() {
        print("time exe")
    }
    override func viewWillAppear(_ animated: Bool) {
        
    }
    override func viewDidAppear(_ animated: Bool) {
        
    }
}


